import common.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tmh
 * @date 2024/9/28 17:13
 * @description
 */
public class T94二叉树的中序遍历 {
    private List<Integer> list=new ArrayList<>();
    public List<Integer> inorderTraversal(TreeNode root) {
        dfs(root);
        return list;
    }

    private void dfs(TreeNode root){
        if (root==null){
            return;
        }
        dfs(root.left);
        list.add(root.val);
        dfs(root.right);
    }
}
